# from rich import print

from dw import *
from utils.custom_types import *
from utils.tools import *


# !!! calculate_angle
def test_1():
    data01 = [
        [0, 35, 501, 182],
        [0, 182, 501, 35],
        [0, 182, 501, 182],  # x1<x2, y1=y2
        [200, 182, 200, 82],  # x1=x2, y1>y2
        [200, 82, 200, 182],  # x1=x2, y1<y2
        [501, 35, 0, 182],
        [501, 182, 0, 35],
        [501, 35, 0, 35],  # x1>x2, y1=y2
        # other
    ]

    for line in data01:
        print(m.degrees(get_angle_between_lines(line)))

# !!!  normalize_line_data
def test_2():
    data02 = [
        [10, 20, 40, 50],
        [10, 80, 40, 50],
        # [0, 396, 502, 250],
        # [0, 361, 502, 227],
        # [0, 325, 502, 203],
        # [0, 322, 500, 201],
        # [0, 255, 502, 157],
        # [0, 253, 502, 154],
        # [0, 222, 502, 135],
        # [0, 219, 502, 132],
        # [0, 189, 499, 113],
        # [0, 186, 502, 110],
        # [0, 157, 502, 91],
        # [0, 126, 502, 70],
        # [0, 123, 497, 69],
        # [0, 96, 421, 58],
        # [0, 94, 502, 48],
        # [0, 64, 502, 27],
        # [0, 37, 502, 11],
        # [0, 34, 502, 8],
        # [1, 398, 502, 252],
        # [1, 289, 502, 180],
        # [1, 66, 499, 31],
        # [2, 357, 501, 225],
        # [2, 321, 502, 200],
        # [2, 286, 502, 177],
        # [2, 255, 346, 188],
        # [3, 189, 502, 113],
        # [4, 154, 502, 89],
        # [5, 185, 501, 110],
        # [7, 432, 502, 275],
        # [8, 285, 485, 181],
        # [13, 433, 500, 278],
        # [39, 384, 497, 251],
        # [48, 385, 501, 253],
        # [121, 432, 502, 301],
        # [128, 432, 501, 304],
        # [139, 83, 502, 51]
    ]

    temp = normalize_line_data(data02)
    print("normalize_line_data")
    print(temp)
    print("compare angle")
    for d1, d2 in zip(data02, temp):
        # if m.degrees(calculate_angle(d1)) != m.degrees(calculate_angle(d2)):
        print(m.degrees(get_angle_between_lines(d1)), m.degrees(get_angle_between_lines(d2)))

# !!!  alter_coordinate_origin
def test_3():
    data03 = [
        [0, 10, 502, 20],
        [0, 30, 502, 40],
        [502, 20, 0, 10],
        [502, 40, 0, 30],
    ]

    temp = alter_coordinate_origin(data03, 100)
    print(temp)

# !!!  get_point_quadrant
def test_4():
    data04 = [
        [10, 20],
        [10, -20],
        [-10, -20],
        [-10, 20],
        [0, 0],
        [-10, 0],
        [0, 20],
    ]

    for data in data04:
        print(get_point_quadrant(*data))

if __name__ == "__main__":
    test_1()
